package com.design.designmode.struct.flyweight;

import java.util.Random;

/**
 * @author hxl
 * @since 2023-04-17
 */
public class Main {
    public static void main(String[] args) {
        ShapeFactory factory = new ShapeFactory();

        Random random = new Random();
        String[] colors = {"red", "blue", "green", "white", "black"};

        for (int i = 1; i <= 100; i++) {
            int x = random.nextInt(colors.length); // [0 ~ 4]
            Shape shape = factory.getShape(colors[x]);

            System.out.print("第" + i + "个圆：");
            shape.draw(random.nextInt(2022), random.nextInt(528));
        }

    }
}
